﻿
using System.Collections.Generic;
using umbraco;
using umbraco.interfaces;

namespace ProlificNotion.Umbraco.MediaSorter
{
    public class SortMediaNodesTree : loadMedia
    {
        public SortMediaNodesTree(string application) : base(application) { }

        protected override void CreateRootNodeActions(ref List<IAction> actions)
        {
            base.CreateAllowedActions(ref actions);
            //- Clone the base actions
            List<IAction> rootNodeActions = new List<IAction>(actions);

            //- Clear the list so we can inject our new menu item where we want it
            actions.Clear();

            //- Iterate through the base actions
            foreach (IAction action in rootNodeActions)
            {
                actions.Add(action);
                if (action.Alias.ToLower() == "sort")
                {
                    //- Add our new action in required location
                    actions.Add(SortAction.Instance);
                }
            } 
        }

    }
}
